﻿<!doctype html>
<html lang="">

<head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">

    <title>@ViewBag.Title</title>

    <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    @Scripts.Render("~/bundles/jquery")
</head>

<body>
    <div class="app">
        @* Thanh menu top *@
        @Html.Partial("_Navbar")
        <section class="layout">

            @* Menu ben trai *@
            @Html.Partial("_SideBar")

            <section class="main-content">

                <div class="content-wrap">
                    <div class="wrapper p10" id="content-main">
                        @* Phan noi dung chinh *@
                        @RenderBody()
                    </div>
                    <div id="loading-icon">
                        <img src="~/Content/css/img/loading.gif" />
                    </div>
                </div>

                <a class="exit-offscreen"></a>
            </section>

            @Html.Partial("_ChatPanel")
        </section>
    </div>
    <div id="notification"></div>


    @Scripts.Render("~/bundles/script")

    @Styles.Render("~/Content/css/admin")
    @*<script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>*@
    @Scripts.Render("~/bundles/jqueryval")
    

    <script>
     
        function cbChonTat(objRef)
        {
            var GridView = objRef.parentNode.parentNode.parentNode.parentNode.parentNode;            
            var inputList = GridView.getElementsByTagName("input");
            for (var i = 0; i < inputList.length; i++)
            {
                var row = inputList[i].parentNode.parentNode;
                if (inputList[i].type == "checkbox" && objRef != inputList[i])
                {
                    if (objRef.checked)
                    {
                        inputList[i].checked = true;
                    }
                    else
                    {
                        inputList[i].checked = false;
                    }
                }
            }
        }

        //$('#delete-all').click(function ()
        //{
        //    var grid = $("#griddata").data("kendoGrid");
        //    $('#griddata').kendoGrid({ editable: { confirmation: false } })
        //    $("#griddata").find("tbody input:checked").each(function ()
        //    {
        //        grid.removeRow($(this).closest('tr'));
        //    })
        //    $("#griddata").find("thead input:checked").removeAttr('checked')
        //    $('#griddata').kendoGrid({ editable: { confirmation: true } })
        //})
       
        $("#loading-icon").hide();
        function AjaxBegin()
        {
            $('#loading-icon').show();

        }
        function AjaxComplete()
        {
            $("#loading-icon").hide();
        }
        function AjaxFailure(ajaxContext)
        {
            var response = ajaxContext.responseText;
            alert("Error: [" + ajaxContext.ErrorCode + "] " + response);
        }


        function onEdit(e)
        {
            //if (e.model.isNew())
            //{
            //    $('.k-window-title').text("Thêm mới");
            //    //e.container.find("label:first").hide();
            //}
            //else
            //{
            //    $('.k-window-title').text("Sửa dữ liệu");
            //}
        }

        function onRequestEnd(e)
        {
            var grid = $("#griddata").data("kendoGrid");
            var data = grid.dataSource;
            if (e.type == "create" || e.type == "update" || e.type == "destroy")
            {
                var notification = $("#notification").kendoNotification().data("kendoNotification");

                if (!e.response.Errors)
                {
                    if (e.type == "create")
                        data.read();
                    notification.show("Thực hiện thao tác thành công.", "info");
                }
            }
        }

        function onError(e, status)
        {
            if (e.errors)
            {
                var message = "The following errors have occurred:\n";

                $.each(e.errors, function (key, value)
                {
                    if (value.errors)
                    {
                        message += value.errors.join("\n");
                    }
                });

                alert(message);
            }
        }
        $('#main-navigation a[data-ajax=true]').click(function ()
        {
            var pageurl = $(this).attr('href');

            if (pageurl != window.location)
            {
                document.title = $(this).html();
                window.history.pushState({ path: pageurl }, $(this).html(), pageurl);
            }
        });

        window.onpopstate = function ()
        {
            $('#content-main').load(location.href)
        };

        $(document).ready(function () {

            $("#ProvinceID").change(function () {
                var provinceid = $(this).val();
                $("#CommuneID").html('').append($('<option/>', {
                    value: 0,
                    text: "Chọn Huyện..."
                }));
                $.getJSON("/CandidateManagement/GetProvinceByCommune", { matinh: provinceid },
                       function (data) {
                           var select = $("#CommuneID");
                           select.empty();
                           select.append($('<option/>', {
                               value: 0,
                               text: "Chọn Huyện..."
                           }));
                           $.each(data, function (index, itemData) {
                               select.append($('<option/>', {
                                   value: itemData.Value,
                                   text: itemData.Text
                               }));
                           });
                       });
            });
            $("#ProvinceID2").change(function () {
                var provinceid2 = $(this).val();
                $("#HighSchoolID").html('').append($('<option/>', {
                    value: 0,
                    text: "Chọn Trường..."
                }));
                $.getJSON("/CandidateManagement/GetHighSchoolByProvince", { matinh: provinceid2 },
                       function (data) {
                           var select = $("#HighSchoolID");
                           select.empty();
                           select.append($('<option/>', {
                               value: 0,
                               text: "Chọn Trường..."
                           }));
                           $.each(data, function (index, itemData) {
                               select.append($('<option/>', {
                                   value: itemData.Value,
                                   text: itemData.Text
                               }));
                           });
                       });
            });


            //$("#TrainingSystemID").change(function () {
            //    var TSID = $(this).val();
            //    $("#MonThiThem").html('')
            //    $.getJSON("/CandidateManagement/GetGraduateSubjectBySubjectCustom", { mamon: graduatesubjectid },
            //           function (data) {
            //               var select = $("#MonThiThem");
            //               select.empty();
            //               $.each(data, function (index, itemData) {
            //                   select.append('<input type="checkbox" name="checkbox' + index + '" value="' + itemData.Value + '"/>  ' + itemData.Text + '<br/>');
            //               });
            //           });
            //});



            $('.button-next').click(function () {

                if ($('#step-1').children().length > 0) return;

                var changeID = $(this).val
                if ($('#ddlTraningSystem').val() == 0) {
                    $.ajax({
                        url: '/common/Step2_Examination',
                        dataType: 'html',
                        success: function (data) {
                            //alert('0')
                            $('#step-1').html('');
                            $('#step-1').html(data);
                        }
                    });
                }
                else if ($('#ddlTraningSystem').val() == 1) {
                    $.ajax({
                        url: '/common/Step2_RecruitingBasic',
                        dataType: 'html',
                        success: function (data) {
                            //alert('1')
                            $('#step-1').html('');
                            $('#step-1').html(data);
                        }
                    });
                }
                else {
                    $.ajax({
                        url: '/common/Step2_Recruiting',
                        dataType: 'html',
                        success: function (data) {
                            //alert('2')
                            $('#step-1').html('');
                            $('#step-1').html(data);
                            $()
                        }
                    });
                }
            });
            //$('.button-back').click(function () {
            //    if ($('#TrangThaiDangKi').val() == 0) {
            //        $('#thituyen').toggleClass('hide')
            //    }
            //    else if ($('#TrangThaiDangKi').val() == 1) {
            //        $('#xettuyen').toggleClass('hide')

            //    }
            //    else {
            //        $('.xettuyenDH').toggleClass('hide')
            //    }

            //});
        });
        // Vocational school
        $("#GroupVocationalID").change(function () {
            $("#PhylumVocationalID").html('').append($('<option/>', {
                value: 0,
                text: "Chọn Ngành..."
            }));
            var groupid = $(this).val();
            $.getJSON("/CandidateManagement/GetPhylumByGroup", { makhoithi: groupid },
                   function (data) {
                       var select = $("#PhylumVocationalID");
                       select.empty();
                       select.append($('<option/>', {
                           value: 0,
                           text: "Chọn Ngành..."
                       }));
                       $.each(data, function (index, itemData) {
                           select.append($('<option/>', {
                               value: itemData.Value,
                               text: itemData.Text
                           }));
                       });
                   });
        });
        $("#PhylumVocationalID").change(function () {
            var phylumid = $(this).val();
            $("#MajorVocationalID").html('').append($('<option/>', {
                value: 0,
                text: "Chọn Chuyên ngành..."
            }));
            $.getJSON("/CandidateManagement/GetMajorByPhylum", { manganh: phylumid },
                   function (data) {
                       var select = $("#MajorVocationalID");
                       select.empty();
                       select.append($('<option/>', {
                           value: 0,
                           text: "Chọn Chuyên ngành..."
                       }));
                       $.each(data, function (index, itemData) {
                           select.append($('<option/>', {
                               value: itemData.Value,
                               text: itemData.Text
                           }));
                       });
                   });
        });
        $("#ProvinceVocationalID").change(function () {
            var provinceid = $(this).val();
            $("#CommuneVocationalID").html('').append($('<option/>', {
                value: 0,
                text: "Chọn Huyện..."
            }));
            $.getJSON("/CandidateManagement/GetProvinceByCommune", { matinh: provinceid },
                   function (data) {
                       var select = $("#CommuneVocationalID");
                       select.empty();
                       select.append($('<option/>', {
                           value: 0,
                           text: "Chọn Huyện..."
                       }));
                       $.each(data, function (index, itemData) {
                           select.append($('<option/>', {
                               value: itemData.Value,
                               text: itemData.Text
                           }));
                       });
                   });
        });
        $("#ProvinceVocationalID2").change(function () {
            var provinceid2 = $(this).val();
            $("#HighSchoolVocationalID").html('').append($('<option/>', {
                value: 0,
                text: "Chọn Trường..."
            }));
            $.getJSON("/CandidateManagement/GetHighSchoolByProvince", { matinh: provinceid2 },
                   function (data) {
                       var select = $("#HighSchoolVocationalID");
                       select.empty();
                       select.append($('<option/>', {
                           value: 0,
                           text: "Chọn Trường..."
                       }));
                       $.each(data, function (index, itemData) {
                           select.append($('<option/>', {
                               value: itemData.Value,
                               text: itemData.Text
                           }));
                       });
                   });
        });
    </script>
</body>

</html>
